import React, { useEffect, useState } from 'react'



export default function App() {
let [person, setPerson]=useState([{
  id: "001",
  name: "张三"
}, {
  id: "002",
  name: "王五"
}, {
  id: "003",
  name: "王二麻子"
}]);

useEffect(() => {
  console.log("person改变了");
}, [person])


const addPerson = () => {
  setPerson([...person, { id: Date.now(), name: "XXXX" }])
}



  return (
    <div>
      <button onClick={addPerson}>添加数据</button>
      <ul>
        {
          person.map(item => {
            return <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}
